from django.contrib import admin
from django.utils.translation import gettext_lazy as _
from django.contrib.auth.admin import UserAdmin
from .models import User


class CustomUserAdmin(UserAdmin):
    """
    Fix ERRORS:
    <class 'django.contrib.auth.admin.UserAdmin'>: (admin.E108) The value of 'list
    _display[2]' refers to 'first_name', which is not a callable, an attribute of
    'UserAdmin', or an attribute or method on 'user.User'.
    """
    fieldsets = (
        (None, {'fields': ('username', 'password')}),
        (_('Personal info'), {'fields': ('credit', 'email')}),
        (_('Permissions'), {
            'fields': ('is_active', 'is_staff', 'is_superuser', 'groups', 'user_permissions'),
        }),
        (_('Important dates'), {'fields': ('last_login', 'date_joined')}),
    )
    list_display = ('username', 'email', 'is_staff')
    search_fields = ('username', 'email')


admin.site.register(User, CustomUserAdmin)
